<template>
    <div>
        <navBar :navTitle="$t('Zhanghudizhi')" prevPath="my" />
        <van-form ref="refFormCard" class="public-form full-width92">
            <div>
                <div class="inp-label">{{ $t('Zhenshixingming') }}</div>
                <van-field v-model.trim="formCard.username" class="bg-inp" :placeholder="$t('Qingshuzhenshi')" clearable
                    :rules="[{ required: true, message: $t('Qingshuzhenshi') }]" />
            </div>
            <div>
                <div class="inp-label">{{ $t('Haoma') }} CMND/CCCD</div>
                <van-field v-model.trim="formCard.name_id" class="bg-inp" :placeholder="$t('Haoma') + 'CMND/CCCD'" clearable
                    :rules="[{ required: true, message: $t('Qingshuru') + $t('Haoma') + 'CMND/CCCD' }]" />
            </div>
            <van-button block type="info" native-type="submit" class="marTop40" @click="fnBtnSave" v-btn-re-click>{{
                $t('Queren') }}</van-button>
        </van-form>
    </div>
</template>

<script>
import { quser_edit_api } from "@/assets/js/api";

export default {
    name: "myAuthentication",
    data() {
        return {
            formCard: {
                username: "",
                name_id: "",
            },
        }
    },
    methods: {
        /*认证保存*/
        fnBtnSave() {
            this.$refs.refFormCard.validate().then(() => {

                quser_edit_api({
                    id: localStorage.getItem("userId"),
                    username: this.formCard.username,
                    name_id: this.formCard.name_id,
                }).then(res => {
                    if (res.code == 200) {
                        this.$toast(res.msg || "Xác thực thành công！");
                        setTimeout(() => {
                            this.$router.push({
                                name: 'my',
                            })
                        }, 1000)

                    } else {
                        this.$toast(res.msg || "Quá trình xác thực đã thất bại！");
                    }
                })
            }).catch(res => { })

        },
    },
    created() {

    },
}
</script>
